﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <WtmSearcher v-model="searchDataEquipment" @search="()=>{getTableDataEquipment();}">
      <el-row>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="EquipName_FormItem" prop="EquipName" :label="$t('message.autotrans._Model_Equipment_EquipName')">
            <el-input v-model="searchDataEquipment.EquipName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="EquipCode_FormItem" prop="EquipCode" :label="$t('message.autotrans._Model_Equipment_EquipCode')">
            <el-input v-model="searchDataEquipment.EquipCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="EquipType_FormItem" prop="EquipType" :label="$t('message.autotrans._Model_Equipment_EquipType')">
            <el-select v-model="searchDataEquipment.EquipType" clearable>
               <el-option key="Equipment" value="Equipment" :label="$t('message.autotrans._Enum_EquipTypeEnum_Equipment')"></el-option>
               <el-option key="Tooling" value="Tooling" :label="$t('message.autotrans._Enum_EquipTypeEnum_Tooling')"></el-option>
               <el-option key="Mould" value="Mould" :label="$t('message.autotrans._Enum_EquipTypeEnum_Mould')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="SpotType_FormItem" prop="SpotType" :label="$t('message.autotrans._Model_Equipment_SpotType')">
            <el-select v-model="searchDataEquipment.SpotType" clearable>
               <el-option key="Barcode" value="Barcode" :label="$t('message.autotrans._Enum_EquipSpotCheckEnum_Barcode')"></el-option>
               <el-option key="Itemized" value="Itemized" :label="$t('message.autotrans._Enum_EquipSpotCheckEnum_Itemized')"></el-option>
               <el-option key="None" value="None" :label="$t('message.autotrans._Enum_EquipSpotCheckEnum_None')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="DriverType_FormItem" prop="DriverType" :label="$t('message.autotrans._Model_Equipment_DriverType')">
            <el-select v-model="searchDataEquipment.DriverType" clearable>
               <el-option key="OpcUa" value="OpcUa" :label="$t('message.autotrans._Enum_DriverTypeEnum_OpcUa')"></el-option>
               <el-option key="None" value="None" :label="$t('message.autotrans._Enum_DriverTypeEnum_None')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="IpAddress_FormItem" prop="IpAddress" :label="$t('message.autotrans._Model_Equipment_IpAddress')">
            <el-input v-model="searchDataEquipment.IpAddress" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Port_FormItem" prop="Port" :label="$t('message.autotrans._Model_Equipment_Port')">
            <el-input v-model="searchDataEquipment.Port" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Actvie_FormItem" prop="Actvie" :label="$t('message.autotrans._Model_Equipment_Actvie')">
            <el-select v-model="searchDataEquipment.Actvie" clearable>
               <el-option :key="1" :value=true :label="$t('message._system.common.vm.tips_bool_true')"></el-option>
               <el-option :key="0" :value=false :label="$t('message._system.common.vm.tips_bool_false')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Manufactor_FormItem" prop="Manufactor" :label="$t('message.autotrans._Model_Equipment_Manufactor')">
            <el-input v-model="searchDataEquipment.Manufactor" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateTime_FormItem" prop="CreateTime" :label="$t('message.autotrans._Model_Equipment_CreateTime')">
            <el-date-picker v-model="searchDataEquipment.CreateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateTime_FormItem" prop="UpdateTime" :label="$t('message.autotrans._Model_Equipment_UpdateTime')">
            <el-date-picker v-model="searchDataEquipment.UpdateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateBy_FormItem" prop="CreateBy" :label="$t('message.autotrans._Model_Equipment_CreateBy')">
            <el-input v-model="searchDataEquipment.CreateBy" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateBy_FormItem" prop="UpdateBy" :label="$t('message.autotrans._Model_Equipment_UpdateBy')">
            <el-input v-model="searchDataEquipment.UpdateBy" clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

  </WtmSearcher>

  <div style="text-align: right;">
      <WtmButton v-auth="'/api/EquipmentManagement/Equipment/Create'" icon='fa fa-plus' type='primary' :button-text="$t('message.autotrans.SysCreate')" @click="OnCreateClick()"/>
    <WtmButton v-auth="'/api/EquipmentManagement/Equipment/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" @click="onBatchDelete()"/>
    <WtmButton v-auth="'/api/EquipmentManagement/Equipment/BatchEdit'" icon='fa fa-pencil-square' type='primary' :button-text="$t('message.autotrans.SysBatchEdit')" @click="OnBatchEditClick()"/>
    <WtmButton v-auth="'/api/EquipmentManagement/Equipment/Import'" icon='fa fa-tasks' type='primary' :button-text="$t('message.autotrans.SysImport')" @click="OnImportClick()"/>
    <WtmButton v-auth="'/api/EquipmentManagement/Equipment/EquipmentExportExcel'"  icon='fa fa-arrow-circle-down' type='primary' :button-text="$t('message.autotrans.SysExport')" @click="onExport()"/>

  </div>
  <WtmTable ref="tableRefEquipment" v-bind="tableDataEquipment">
    <template #operation>
      <el-table-column :label="$t('message._system.common.vm.operate')" width="180">
        <template v-slot="scope">
            <WtmButton v-auth="'/api/EquipmentManagement/Equipment/Edit'" :is-text="true" icon='fa fa-pencil-square' type='warning' :button-text="$t('message.autotrans.SysEdit')" @click="OnEditrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/EquipmentManagement/Equipment/{id}'" :is-text="true" icon='fa fa-info-circle' type='info' :button-text="$t('message.autotrans.Page详情')" @click="OnDetailsrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/EquipmentManagement/Equipment/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" :is-text="true"  @click="onDelete(scope.row)"/>

        </template>
      </el-table-column>
    </template>
  </WtmTable>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageEquipmentManagementEquipmentIndex;true;Digitalmes.EquipmentManagement.Controllers;Equipment">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { equipmentApi } from '/@/api/equipmentmanagement/equipment';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;

const CreateDialog = defineAsyncComponent(() => import('./create.vue'));
const EditDialog = defineAsyncComponent(() => import('./edit.vue'));
const DetailsDialog = defineAsyncComponent(() => import('./details.vue'));
const BatchEditDialog = defineAsyncComponent(() => import('./batchedit.vue'));
const ImportDialog = defineAsyncComponent(() => import('./import.vue'));

const stateEquipment = reactive({
    
});

const searchDataEquipment = ref({
        EquipName: '',
        EquipCode: '',
        EquipType: undefined,
        SpotType: undefined,
        DriverType: undefined,
        IpAddress: '',
        Port: '',
        Actvie: undefined,
        Manufactor: '',
        CreateTime: undefined,
        UpdateTime: undefined,
        CreateBy: '',
        UpdateBy: '',
});

// 定义变量内容
const tableRefEquipment = ref();
const tableDataEquipment = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
      {title:ci.proxy.$t('message.autotrans.Page设备名称'),key: 'Equipment_EquipName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page设备编号'),key: 'Equipment_EquipCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page设备类型'),key: 'Equipment_EquipType',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page点检模式'),key: 'Equipment_SpotType',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page驱动类型'),key: 'Equipment_DriverType',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page网络地址'),key: 'Equipment_IpAddress',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page端口'),key: 'Equipment_Port',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page激活'),key: 'Equipment_Actvie',type: 'switch',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page生产厂家'),key: 'Equipment_Manufactor',type: 'text',isCheck: true},
    //   {title:ci.proxy.$t('message.autotrans._AdminCreateTime'),key: 'Equipment_CreateTime',type: 'text',isCheck: true},
    //   {title:ci.proxy.$t('message.autotrans._AdminUpdateTime'),key: 'Equipment_UpdateTime',type: 'text',isCheck: true},
    //   {title:ci.proxy.$t('message.autotrans._AdminCreateBy'),key: 'Equipment_CreateBy',type: 'text',isCheck: true},
    //   {title:ci.proxy.$t('message.autotrans._AdminUpdateBy'),key: 'Equipment_UpdateBy',type: 'text',isCheck: true},

	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: true, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
	}
});
// 初始化表格数据
const getTableDataEquipment = () => {
    tableRefEquipment.value.doSearch(equipmentApi().search, searchDataEquipment.value)
        .catch((error: any) => {
			other.setFormError(ci, error);
		});
};
const OnCreateClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysCreate'), CreateDialog, null, getTableDataEquipment)
};

const OnEditrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysEdit'), EditDialog, row, getTableDataEquipment)
};

const OnDetailsrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.Page详情'), DetailsDialog, row, getTableDataEquipment)
};

// 删除
const onDelete = (row: any) => {
    equipmentApi().delete([row.ID]).then(() => { getTableDataEquipment()})
};

const onBatchDelete = () => {
    const selectedrows = tableRefEquipment.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      equipmentApi().delete(selectedids).then(() => { getTableDataEquipment()})
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnBatchEditClick = () => {
    const selectedrows = tableRefEquipment.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      other.openDialog(ci.proxy.$t('message.autotrans.SysBatchEdit'), BatchEditDialog, selectedids, getTableDataEquipment)
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnImportClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysImport'), ImportDialog, null, getTableDataEquipment)
};

const onExport = () => {
	const selected = tableRefEquipment.value.getSelectedRows();
	if (selected.length > 0) {
		equipmentApi().exportById(selected.map((x: any) => x.ID));
	}
	else {
		equipmentApi().export(searchDataEquipment.value);
	}
};

// 页面加载时
onMounted(() => {
    
        getTableDataEquipment();

});

// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

